# -*- coding: utf-8 -*-
# @Author : zhaochen
# @Date   : 2019/1/22
# @File   : TX01_TaxpayerType.py
# @E-mail : zhaochen@bbdservice.com

'''eof
name:纳税人类型
code:TX01_TaxpayerType
tableName:
columnName:
groups:税务模块
dependencies:TX_CQ_DSJ
type:常用指标
datasourceType:在线指标
description:
eof'''

import sys
import re
import datetime
reload(sys)
sys.setdefaultencoding('utf-8')

null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--']

def getTable(table_Name):
    '''
    获取表
    :param x:
    :return:
    '''
    try:
        ic_data = TX_CQ_DSJ['data'].get(table_Name)
        if ic_data in null_type_list:
            return None
        else:
            return ic_data if isinstance(ic_data, list) and len(ic_data) > 0 else [{}]
    except:
        return None

def TX01_TaxpayerType():
    try:
        syptSwdjxx = getTable('syptSwdjxx')
        if syptSwdjxx == [{}] or syptSwdjxx is None:
            return u'缺失值'
        else:
            NSRZG_DM = syptSwdjxx[0].get('NSRZG_DM')
            if NSRZG_DM in null_type_list:
                return u'缺失值'
            elif NSRZG_DM not in null_type_list and NSRZG_DM in ['201', '202', '203', '204', '205']:
                return NSRZG_DM
            else:
                return u'其他'
    except:
        return u'缺失值'

result = TX01_TaxpayerType()